package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TNurseMapper;
import com.ruoyi.system.domain.TNurse;
import com.ruoyi.system.service.ITNurseService;
import com.ruoyi.common.core.text.Convert;

/**
 * 护士Service业务层处理
 * 
 * @author 杨一迪
 * @date 2024-12-26
 */
@Service
public class TNurseServiceImpl extends ServiceImpl<TNurseMapper,TNurse> implements ITNurseService

{
    @Autowired
    private TNurseMapper tNurseMapper;

    /**
     * 查询护士
     * 
     * @param id 护士主键
     * @return 护士
     */
    @Override
    public TNurse selectTNurseById(Long id)
    {
        return tNurseMapper.selectTNurseById(id);
    }

    /**
     * 查询护士列表
     * 
     * @param tNurse 护士
     * @return 护士
     */
    @Override
    public List<TNurse> selectTNurseList(TNurse tNurse)
    {
        return tNurseMapper.selectTNurseList(tNurse);
    }

    /**
     * 新增护士
     * 
     * @param tNurse 护士
     * @return 结果
     */
    @Override
    public int insertTNurse(TNurse tNurse)
    {
        tNurse.setCreateTime(DateUtils.getNowDate());
        return tNurseMapper.insertTNurse(tNurse);
    }

    /**
     * 修改护士
     * 
     * @param tNurse 护士
     * @return 结果
     */
    @Override
    public int updateTNurse(TNurse tNurse)
    {
        tNurse.setUpdateTime(DateUtils.getNowDate());
        return tNurseMapper.updateTNurse(tNurse);
    }

    /**
     * 批量删除护士
     * 
     * @param ids 需要删除的护士主键
     * @return 结果
     */
    @Override
    public int deleteTNurseByIds(String ids)
    {
        return tNurseMapper.deleteTNurseByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除护士
     *
     * @param ids 需要软删除的护士主键
     * @return 结果
     */
    @Override
    public int softDeleteTNurseByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            TNurse tNurse = tNurseMapper.selectTNurseById(Long.valueOf(s));
            tNurse.setIsDelete(1);
            int i = tNurseMapper.updateTNurse(tNurse);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除护士信息
     * 
     * @param id 护士主键
     * @return 结果
     */
    @Override
    public int deleteTNurseById(Long id)
    {
        return tNurseMapper.deleteTNurseById(id);
    }
}
